﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;
using ModuleDALCore;

namespace DAL
{
	public class CT_KHAMBENHDAO:DALBase
	{
		public CT_KHAMBENHDAO()
		{
			this.OpenConnect();
		}
		private DataTable dt;
		private string _SpName;
		public string SpName
		{
			get { return "SPCT_KHAMBENH"; }
			set { _SpName = value; }
		}
		public List<CT_KHAMBENH> GETLISKB(CT_KHAMBENH cv)
		{
			dt = new DataTable();
			List<CT_KHAMBENH> bc = new List<CT_KHAMBENH>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 3));
				bc = (List<CT_KHAMBENH>)ConvertDatatableToList.ConvertTo<CT_KHAMBENH>(dt);
				return bc;
			}
			catch { return null; }
		}
		public List<CT_KHAMBENH> GETLISTIDNGAYTHUCHIEN(CT_KHAMBENH cv)
		{
			dt = new DataTable();
			List<CT_KHAMBENH> bc = new List<CT_KHAMBENH>();
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 5));
				bc = (List<CT_KHAMBENH>)ConvertDatatableToList.ConvertTo<CT_KHAMBENH>(dt);
				return bc;
			}
			catch { return null; }
		}
		public DataTable GETDETAILKB(CT_KHAMBENH cv)
		{
			dt = new DataTable();
			
			try
			{

				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 4));

				return dt;

			}
			catch { return null; }
		}
		public CT_KHAMBENH GETACTKB(CT_KHAMBENH cv)
		{
			dt = new DataTable();
			CT_KHAMBENH bc = new CT_KHAMBENH();
			try
			{
				dt = DBManager.Intance.ExecuteDataTable(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 7));
				bc = (CT_KHAMBENH)ConvertDatatableToList.ConvertToObject<CT_KHAMBENH>(dt);
				return bc;
			}
			catch { return null; }
		}
		public bool ISDELETE(CT_KHAMBENH cv)
		{

			try
			{
				return (DBManager.Intance.ExecuteNonQuery(SpName, ConvertClassToArray.GetParamName(cv, null), ConvertClassToArray.GetValues(cv, 6)) == 1);

			}
			catch { return false; }
		}
	}
}
